
<template>
  <div class="common-layout">
    <el-container>
      <el-aside class="mainasi">
        <image-preview :src="logo" width="40px" style="margin: 20px 0 0 20px"></image-preview>
        <div class="tabs">
          <button
            v-for="(tab, index) in tabs"
            :key="index"
            :class="{ active: currentTab === index }"
            @click="currentTab = index"
          >
            <el-icon><Search /></el-icon>
            {{ tab.name }}
          </button>
        </div>
      </el-aside>
      <el-container>
        <el-header>
          <el-image style="height: 40px;border-radius: 50%;margin: 10px 20px 10px 10px;float: right" :src="logo" fit="fill" />
          <el-button type="primary" :icon="Search" style="margin: 10px 20px 10px 10px;float: right">订阅企业</el-button>
        </el-header>
        <el-main>
          <div class="tab-content">
            <div
              v-for="(tab, index) in tabs"
              :key="index"
              :class="{ 'content-active': currentTab === index }"
            >
              <h2>{{ tab.name }}</h2>
              <p>{{ tab.content }}</p>
            </div>
          </div>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script setup lang="ts">
import {Search} from "@element-plus/icons-vue";

const logo = 'https://qny.sunne.xyz/static/img/kmm/02Logo.png';

  const currentTab = ref(0);
  const tabs = [
    { name: 'Tab 1', content: 'This is the content of Tab 1' },
    { name: 'Tab 2', content: 'This is the content of Tab 2' },
    { name: 'Tab 3', content: 'This is the content of Tab 3' },
  ];

</script>

<style scoped lang="scss">
.mainasi{
  height: max(calc(100vh), 800px);
  width: max(200px, 160px);
  padding: 0;
}
.maincon{
  width: max(calc(100vw - 160px),800px);
}
.fr{
  float: right;
}
.inheader{
  display: flex;
  justify-content: center; /* 水平居中 */
  height: 60px;
}
.tabs {
  margin-top: 40px;
  justify-content: center;
  margin-bottom: 20px;
}

.tabs button {
  text-align: left;
  width: 160px;
  height: 40px;
  padding: 10px 20px;
  margin: 5px 5px;
  color: #171616;
  border: none;
  cursor: pointer;
  border-radius: 15px;
  transition: background-color 0.3s ease;
}

.tabs button.active {
  background-color: #8093dc;
  color: whitesmoke;
  font-size: 16px;
  font-weight: bold;
}

.tab-content {
  display: flex;
  overflow: hidden;
  width: max(calc(100vw - 200px),800px);
  position: relative;
}

.tab-content > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  opacity: 0;
  transform: translateX(100%);
  transition: transform 0.5s ease, opacity 0.5s ease;
}

.tab-content > div.content-active {
  opacity: 1;
  transform: translateX(0);
}

.tab-content > div:nth-child(2) {
  transform: translateX(-100%);
}

.tab-content > div.content-active:nth-child(2) {
  transform: translateX(0);
}
.maincontent{
  width: 100%;
  height: 100%;
}
</style>
